package com.eastedu.template.exception;

import com.eastedu.template.model.ReportResult;
import lombok.extern.slf4j.Slf4j;

/**
 * The interface Report generate callback.
 *
 * @author superman
 */
public interface ReportGenerateCallback {

    /**
     * Success.
     *
     * @param taskId the task id
     * @param result the result
     */
    void success(String taskId, ReportResult result);

    /**
     * Failure.
     *
     * @param taskId    the task id
     * @param throwable the throwable
     */
    void failure(String taskId, Throwable throwable);


    /**
     * The type Default report generate callback.
     */
    @Slf4j
    class DefaultReportGenerateCallback implements ReportGenerateCallback {
        @Override
        public void success(String taskId, ReportResult result) {
            // do nothing
            log.info("Report generate success, taskId: {}", taskId);
        }

        @Override
        public void failure(String taskId, Throwable throwable) {
            // do nothing
            log.error("Report generate failure, taskId: {}", taskId, throwable);
        }
    }
}
